import sys,os
import random
import string
import data
import pygame
from pygame.locals import *

class World():
	'''Creates a world that we can fill in later, for now I will just make it "1"'s'''
	
	def __init__(self, screen):
		self.screen = screen
		
		self.grass = data.image(os.path.join("core","images","tiles","grass.png"))
		self.water = data.image(os.path.join("core","images","tiles","water.png"))
		self.tropical = data.image(os.path.join("core","images","tiles","tropical.png"))
		self.sand = data.image(os.path.join("core","images","tiles","sand.png"))
		
		self.textures = {'Gg' : self.grass,
						'Sw' : self.water,
						'Tt' : self.tropical,
						'Bs' : self.sand }
		
		self.move = [0,0]
	
	def create_map(self, msizex, msizey):
		self.msizex = msizex
		self.msizey = msizey
		
		self.map = []
		for i in range(0,self.msizey):
			row = []
			for i in range(0,self.msizex):
				row.append()
			self.map.append(row)
			#print row
	
	def load_map(self, map):
		self.map = map
	
	def update(self, direction):
		self.move = direction
	
	def render(self):
		x = 0
		y = 0
		render_pos = []
		self.screen.fill([0,0,0])
		for i in self.map:
			for j in self.map[y]:
				if(y%2 == 0 and y == 0):
					self.screen.blit(self.textures[j],(x*98+int(self.move[0]),0+int(self.move[1])))
				elif(y%2 == 0):
					self.screen.blit(self.textures[j],(x*98+int(self.move[0]),y*49-(y/2*49)+int(self.move[1])))
				elif(y%2 == 1 and y == 1):
					self.screen.blit(self.textures[j],(x*98+49+int(self.move[0]),y*49-25+int(self.move[1])))
				elif(y%2 == 1):
					self.screen.blit(self.textures[j],(x*98+49+int(self.move[0]),y*49-(y/2*49)-25+int(self.move[1])))
				x += 1
			y += 1
			x = 0
		pygame.display.flip()